
**# Step 1 
********************************************************************************
* Data collection from Thomson Reuters Datastream Excel add-in
* Clean data in Excel and re-arrange into panel format, keeping only corporate entities with non-missing industry codes, excluding financials, public/other sectors, and firms with non-positive total assets
* Import data from Excel into Stata and destring
* Arrange data and delete outliers 
********************************************************************************

*Outliars treatment
xtset code year
gen BP=BVPS/Price
gen EP=EPS/Price
drop if missing(BP)
drop if missing(EP)
univar BP EP
summarize BP, detail
gen DeleteBP=BP if BP<r(p1)|BP>r(p99)
summarize EP, detail
gen DeleteEP=EP if EP<r(p1)|EP>r(p99)
drop if BP==DeleteBP
drop if EP==DeleteEP

gen PB=Price/BVPS
gen PE=Price/EPS


**# Step 2 
********************************************************************************
* Fama-MacBeth regression on LIM parameters 
* Calculate theoretical implied valuation multiples
* Calculate estimated equity value in each model 
********************************************************************************

*O95
xtset code year
gen BVPS_lag1=L.BVPS
gen RIPS=EPS-CostofEquity*BVPS_lag1
gen RIPS_lag1=L.RIPS
gen D_RIPS=RIPS/BVPS_lag1
gen D_RIPS_lag1=RIPS_lag1/BVPS_lag1

foreach var of varlist D_RIPS D_RIPS_lag1 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen O95w11=.

forval i = 1990/2022 {
asreg D_RIPS D_RIPS_lag1 if year<=`i', fmb
replace O95w11=_b[D_RIPS_lag1] if year==`i'
}

gen BetaO951=O95w11/(1+CostofEquity-O95w11)
tab BetaO951
gen VO95=BVPS+BetaO951*RIPS

*O95ADO
gen VO95_lag1=L.VO95
gen VO95_lag2=L.VO95_lag1
gen VO95_lag3=L.VO95_lag2
gen VO95_lag4=L.VO95_lag3
gen R1O95=(VO95-VO95_lag1)/VO95_lag1
gen R2O95=(VO95_lag1-VO95_lag2)/VO95_lag2
gen R3O95=(VO95_lag2-VO95_lag3)/VO95_lag3
gen R4O95=(VO95_lag3-VO95_lag4)/VO95_lag4
gen AverageO95=(R1O95+R2O95+R3O95+R4O95)/4
gen VarianceO95=((R1O95-AverageO95)^2+(R2O95-AverageO95)^2+(R3O95-AverageO95)^2+(R4O95-AverageO95)^2)/3
gen SDO95=sqrt(VarianceO95)
gen theta=2*CostofEquity/VarianceO95
gen thetaB=theta*BVPS
gen h=VO95/BVPS
sum theta, detail
sum thetaB, detail
sum h, detail
gen a0=thetaB*log10(thetaB/(1+thetaB))+2
gen a1=-1-thetaB/(1+thetaB)-thetaB*log10(thetaB/(1+thetaB))
gen l0=1
gen l1=1-h
forval i = 2/20 {
gen a`i'= (thetaB*(1+thetaB)^`i'- thetaB^`i'*(`i'+thetaB))/(`i'*(`i'-1)*(1+thetaB)^`i')
local j=`i'-1
local k=`i'-2
gen l`i'= ((2*`i'-1-h)*l`j'-(`i'-1)*l`k')/`i'
}
gen Va=a0*l0
forval i = 1/20 {
replace Va= a`i'*l`i'+Va
}
replace Va=1 if h<=0&!missing(Va)

gen VA=Va*BVPS
univar VA
drop theta thetaB h a0 a1 l0 l1 a2 l2 a3 l3 a4 l4 a5 l5 a6 l6 a7 l7 a8 l8 a9 l9 a10 l10 a11 l11 a12 l12 a13 l13 a14 l14 a15 l15 a16 l16 a17 l17 a18 l18 a19 l19 a20 l20

*O95ABO 
gen T=5
gen O95d1=(ln(VO95/BVPS)+(rf+VarianceO95/2)*T)/(SDO95*sqrt(T))
gen O95d2=O95d1-SDO95*sqrt(T)
gen O95Nd1=normal(O95d1)
gen O95Nd2=normal(O95d2)
gen O95Call=VO95*O95Nd1-BVPS*exp(-rf*T)*O95Nd2
replace O95Call=0 if VO95<=BVPS&!missing(BVPS)
gen VBO95=BVPS+O95Call
replace VBO95=. if missing(O95d1)
replace VBO95=BVPS if VO95<=BVPS&!missing(BVPS)
drop T

*O95GO
gen D_KGO3Y=KGO3Y/BVPS_lag1
gen KGO3Y_lag1=L.KGO3Y
gen D_KGO3Y_lag1=KGO3Y_lag1/BVPS_lag1
winsor2 D_KGO3Y, cuts(1 99) by(year_)
rename D_KGO3Y oD_KGO3Y
rename D_KGO3Y_w D_KGO3Y
winsor2 D_KGO3Y_lag1, cuts(1 99) by(year_)
rename D_KGO3Y_lag1 oD_KGO3Y_lag1
rename D_KGO3Y_lag1_w D_KGO3Y_lag1

gen O95KGO3Yw11=.
gen O95KGO3Yw12=.
forval i = 1993/2022 {
asreg D_RIPS D_RIPS_lag1 D_KGO3Y_lag1 if year<=`i', fmb
replace O95KGO3Yw11=_b[D_RIPS_lag1] if year==`i'
replace O95KGO3Yw12=_b[D_KGO3Y_lag1] if year==`i'
}

gen O95KGO3Yw22=.
forval i = 1993/2022 {
asreg D_KGO3Y D_KGO3Y_lag1 if year<=`i', fmb
replace O95KGO3Yw22=_b[D_KGO3Y_lag1] if year==`i'
}

gen BetaO95KGO3Y1=O95KGO3Yw11/(1+CostofEquity-O95KGO3Yw11)
gen BetaO95KGO3Y2=(1+CostofEquity)*O95KGO3Yw12/((1+CostofEquity-O95KGO3Yw11)*(1+CostofEquity-O95KGO3Yw22))
gen VO95KGO3Y=BVPS+BetaO95KGO3Y1*RIPS+BetaO95KGO3Y2*KGO3Y

*O95GOABO
gen VO95KGO3Y_lag1=L.VO95KGO3Y
gen VO95KGO3Y_lag2=L.VO95KGO3Y_lag1
gen VO95KGO3Y_lag3=L.VO95KGO3Y_lag2
gen VO95KGO3Y_lag4=L.VO95KGO3Y_lag3
gen R1O95KGO3Y=(VO95KGO3Y-VO95KGO3Y_lag1)/VO95KGO3Y_lag1
gen R2O95KGO3Y=(VO95KGO3Y_lag1-VO95KGO3Y_lag2)/VO95KGO3Y_lag2
gen R3O95KGO3Y=(VO95KGO3Y_lag2-VO95KGO3Y_lag3)/VO95KGO3Y_lag3
gen R4O95KGO3Y=(VO95KGO3Y_lag3-VO95KGO3Y_lag4)/VO95KGO3Y_lag4
gen AverageO95KGO3Y=(R1O95KGO3Y+R2O95KGO3Y+R3O95KGO3Y+R4O95KGO3Y)/4
gen VarianceO95KGO3Y=((R1O95KGO3Y-AverageO95KGO3Y)^2+(R2O95KGO3Y-AverageO95KGO3Y)^2+(R3O95KGO3Y-AverageO95KGO3Y)^2+(R4O95KGO3Y-AverageO95KGO3Y)^2)/3
gen SDO95KGO3Y=sqrt(VarianceO95KGO3Y)
gen T=5
gen O95KGO3Yd1=(ln(VO95KGO3Y/BVPS)+(rf+VarianceO95KGO3Y/2)*T)/(SDO95KGO3Y*sqrt(T))
gen O95KGO3Yd2=O95KGO3Yd1-SDO95KGO3Y*sqrt(T)
gen O95KGO3YNd1=normal(O95KGO3Yd1)
gen O95KGO3YNd2=normal(O95KGO3Yd2)
gen O95KGO3YCall=VO95KGO3Y*O95KGO3YNd1-BVPS*exp(-rf*T)*O95KGO3YNd2
replace O95KGO3YCall=0 if VO95KGO3Y<=BVPS&!missing(BVPS)
gen VBO95KGO3Y=BVPS+O95KGO3YCall
replace VBO95KGO3Y=. if missing(O95KGO3Yd1)
replace VBO95KGO3Y=BVPS if VO95KGO3Y<=BVPS&!missing(BVPS)
drop T 

*FO95
gen NOAPS_lag1=L.NOAPS
gen ROIPS=NOIPS-CostofEquity*NOAPS_lag1
gen ROIPS_lag1=L.ROIPS
gen D_ROIPS=ROIPS/BVPS_lag1
gen D_ROIPS_lag1=ROIPS_lag1/BVPS_lag1
gen D_NOAPS=NOAPS/BVPS_lag1
gen D_NOAPS_lag1=NOAPS_lag1/BVPS_lag1

foreach var of varlist D_ROIPS D_ROIPS_lag1 D_NOAPS D_NOAPS_lag1 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen FO95w11=.
gen FO95w12=.
gen FO95w22=.

forval i = 1990/2022 {
asreg D_ROIPS D_ROIPS_lag1 D_NOAPS_lag1 if year<=`i', fmb
replace FO95w11=_b[D_ROIPS_lag1] if year==`i'
replace FO95w12=_b[D_NOAPS_lag1] if year==`i'
}

forval i = 1990/2022 {
asreg D_NOAPS D_NOAPS_lag1 if year>1982&year<=`i', fmb
replace FO95w22=_b[D_NOAPS_lag1] if year==`i'
}

gen BetaFO951=FO95w11/(1+CostofEquity-FO95w11)
gen BetaFO952=FO95w12*(1+CostofEquity)/((1+CostofEquity-FO95w22)*(1+CostofEquity-FO95w11))
gen VFO95=BVPS+BetaFO951*ROIPS+BetaFO952*NOAPS

*FO95ABO
gen VFO95_lag1=L.VFO95
gen VFO95_lag2=L.VFO95_lag1
gen VFO95_lag3=L.VFO95_lag2
gen VFO95_lag4=L.VFO95_lag3
gen R1FO95=(VFO95-VFO95_lag1)/VFO95_lag1
gen R2FO95=(VFO95_lag1-VFO95_lag2)/VFO95_lag2
gen R3FO95=(VFO95_lag2-VFO95_lag3)/VFO95_lag3
gen R4FO95=(VFO95_lag3-VFO95_lag4)/VFO95_lag4
gen AverageFO95=(R1FO95+R2FO95+R3FO95+R4FO95)/4
gen VarianceFO95=((R1FO95-AverageFO95)^2+(R2FO95-AverageFO95)^2+(R3FO95-AverageFO95)^2+(R4FO95-AverageFO95)^2)/3
gen SDFO95=sqrt(VarianceFO95)

gen T=5
gen FO95d1=(ln(VFO95/BVPS)+(rf+VarianceFO95/2)*T)/(SDFO95*sqrt(T))
gen FO95d2=FO95d1-SDFO95*sqrt(T)
gen FO95Nd1=normal(FO95d1)
gen FO95Nd2=normal(FO95d2)
gen FO95Call=VFO95*FO95Nd1-BVPS*exp(-rf*T)*FO95Nd2
replace FO95Call=0 if VFO95<=BVPS&!missing(BVPS)
gen VBFO95=BVPS+FO95Call
replace VBFO95=. if missing(FO95d1)
replace VBFO95=BVPS if VFO95<=BVPS&!missing(BVPS)
drop T

**FO96
gen CIPS_lag1=L.CIPS
gen CRPS_lag1=L.CRPS
gen D_CIPS=CIPS/BVPS_lag1
gen D_CIPS_lag1=CIPS_lag1/BVPS_lag1
gen D_CRPS=CRPS/BVPS_lag1
gen D_CRPS_lag1=CRPS_lag1/BVPS_lag1
gen D_NOALCI=(NOAPS-CIPS)/BVPS_lag1

foreach var of varlist D_CRPS D_CRPS_lag1 D_CIPS D_CIPS_lag1 D_NOALCI {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen FO96r11=.
gen FO96r12=.
gen FO96r22=.
gen FO96del=.

forval i = 1998/2022 {
asreg D_CRPS D_CRPS_lag1 D_CIPS_lag1  if year>1994&year<=`i', fmb
replace FO96r11=_b[D_CRPS_lag1] if year==`i'
replace FO96r12=_b[D_CIPS_lag1] if year==`i'
}

forval i = 1990/2022 {
asreg D_CIPS D_CIPS_lag1  if year<=`i', fmb
replace FO96r22=_b[D_CIPS_lag1] if year==`i'
}

forval i = 1990/2022 {
asreg D_NOALCI D_NOAPS_lag1 if year>1982&year<=`i', fmb
replace FO96del=_b[D_NOAPS_lag1] if year==`i'
}

gen FO96phi=1/(1+CostofEquity-FO96r11)
gen BetaFO961=FO96phi*FO96r11
gen BetaFO962=FO96phi*(1+CostofEquity)*(FO96r11-FO96del)
gen BetaFO963=(FO96phi*FO96r12-1)*((1+CostofEquity)/(1+CostofEquity-FO96r22))
gen VFO96=BVPS+BetaFO961*ROIPS+BetaFO962*NOAPS_lag1+BetaFO963*CIPS

*FO96ABO
gen VFO96_lag1=L.VFO96
gen VFO96_lag2=L.VFO96_lag1
gen VFO96_lag3=L.VFO96_lag2
gen VFO96_lag4=L.VFO96_lag3
gen R1FO96=(VFO96-VFO96_lag1)/VFO96_lag1
gen R2FO96=(VFO96_lag1-VFO96_lag2)/VFO96_lag2
gen R3FO96=(VFO96_lag2-VFO96_lag3)/VFO96_lag3
gen R4FO96=(VFO96_lag3-VFO96_lag4)/VFO96_lag4
gen AverageFO96=(R1FO96+R2FO96+R3FO96+R4FO96)/4
gen VarianceFO96=((R1FO96-AverageFO96)^2+(R2FO96-AverageFO96)^2+(R3FO96-AverageFO96)^2+(R4FO96-AverageFO96)^2)/3
gen SDFO96=sqrt(VarianceFO96)

gen T=5
gen FO96d1=(ln(VFO96/BVPS)+(rf+VarianceFO96/2)*T)/(SDFO96*sqrt(T))
gen FO96d2=FO96d1-SDFO96*sqrt(T)
gen FO96Nd1=normal(FO96d1)
gen FO96Nd2=normal(FO96d2)
gen FO96Call=VFO96*FO96Nd1-BVPS*exp(-rf*T)*FO96Nd2
replace FO96Call=0 if VFO96<=BVPS&!missing(BVPS)
gen VBFO96=BVPS+FO96Call
replace VBFO96=. if missing(FO96d1)
replace VBFO96=BVPS if VFO96<=BVPS&!missing(BVPS)
drop T

*CEM
gen CEM=ave_ROE*BVPS/CostofEquity

*CEGOABO
gen PutZhang=(BVPS-(ave_ROE*BVPS)/CostofEquity)/(1+CostofEquity)
replace PutZhang=0 if PutZhang<=0
gen CallZhang=((ave_ROE*CIPS)/CostofEquity-CIPS)/(1+CostofEquity)
replace CallZhang=0 if CallZhang<=0
gen VZhang=ave_ROE*BVPS/CostofEquity+CallZhang+PutZhang

**# Step 3 
********************************************************************************
* Calculate PVE and APVE
* Construct joint sample
* Conduct main analysis and sub-sample analysis
********************************************************************************

*PVE
gen PVEO95=(VO95-Price)/Price
gen PVEVBO95=(VBO95-Price)/Price
gen PVEVA=(VA-Price)/Price
gen PVEFO95=(VFO95-Price)/Price
gen PVEFO96=(VFO96-Price)/Price
gen PVEVBFO95=(VBFO95-Price)/Price
gen PVEVBFO96=(VBFO96-Price)/Price
gen PVEO95KGO3Y=(VO95KGO3Y-Price)/Price
gen PVEVBO95KGO3Y=(VBO95KGO3Y-Price)/Price
gen PVECEM=(CEM-Price)/Price
gen PVEZhang=(VZhang-Price)/Price

*Construct joint sample
drop if missing(PVEO95)
drop if missing(PVEVBO95)
drop if missing(PVEVA)
drop if missing(PVEFO95)
drop if missing(PVEFO96)
drop if missing(PVEVBFO95)
drop if missing(PVEVBFO96)
drop if missing(PVEZhang)
drop if missing(PVECEM)
drop if missing(PVEO95KGO3Y)
drop if missing(PVEVBO95KGO3Y)

*APVE
gen APVEO95=abs(VO95-Price)/Price
gen APVEVBO95=abs(VBO95-Price)/Price
gen APVEVA=abs(VA-Price)/Price
gen APVEFO95=abs(VFO95-Price)/Price
gen APVEFO96=abs(VFO96-Price)/Price
gen APVEVBFO95=abs(VBFO95-Price)/Price
gen APVEVBFO96=abs(VBFO96-Price)/Price
gen APVEO95KGO3Y=abs(VO95KGO3Y-Price)/Price
gen APVEVBO95KGO3Y=abs(VBO95KGO3Y-Price)/Price
gen APVECEM=abs(CEM-Price)/Price
gen APVEZhang=abs(VZhang-Price)/Price

*Wilcoxon signed rank test of median APVE (CEM and CEGOABO as an example)
signrank APVEZhang = APVECEM

*PVE and APVE
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y 
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y 

*Frequency of Accuracy
gen	TAPVEO95 =APVEO95  if APVEO95 <=0.15
gen	TAPVEVBO95=APVEVBO95 if APVEVBO95<=0.15
gen	TAPVEVA=APVEVA if APVEVA<=0.15
gen	TAPVEFO95=APVEFO95 if APVEFO95<=0.15
gen	TAPVEVBFO95=APVEVBFO95 if APVEVBFO95<=0.15
gen	TAPVEFO96=APVEFO96 if APVEFO96<=0.15
gen	TAPVEVBFO96=APVEVBFO96 if APVEVBFO96<=0.15
gen TAPVECEM=APVECEM if APVECEM<=0.15
gen TAPVEZhang=APVEZhang if APVEZhang<=0.15
gen TAPVEO95KGO3Y=APVEO95KGO3Y  if APVEO95KGO3Y<=0.15
gen TAPVEVBO95KGO3Y=APVEVBO95KGO3Y if APVEVBO95KGO3Y<=0.15

scalar drop _all

foreach var of varlist APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y {
univar T`var' 
scalar aT`var' = r(N) 
univar `var' 
scalar b`var' = r(N) 
scalar c`var'=aT`var'/ b`var'
display c`var'
}

*Explainability
gen PutVO95=VBO95-VO95
gen PutVFO95=VBFO95-VFO95
gen PutVFO96=VBFO96-VFO96
gen PutVA=VA-VO95
gen PutVO95KGO3Y=VBO95KGO3Y-VO95KGO3Y
gen GOKGO3Y=VO95KGO3Y-VO95

foreach var of varlist Price VO95 PutVO95 VBO95 PutVA VA VFO95 PutVFO95 VBFO95 VFO96 PutVFO96 VBFO96 VZhang CEM CallZhang PutZhang VO95KGO3Y PutVO95KGO3Y VBO95KGO3Y GOKGO3Y {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var', fmb newey(3) 
}

*Multivariate results on valuation component estimates
asreg Price VO95 PutVO95, fmb newey(3)
asreg Price VO95 PutVA, fmb newey(3)
asreg Price VO95 GOKGO3Y, fmb newey(3)
asreg Price VO95 GOKGO3Y PutVO95K, fmb newey(3)
asreg Price VFO95 PutVFO95, fmb newey(3)
asreg Price VFO96 PutVFO96, fmb newey(3)
asreg Price CEM CallZhang PutZhang, fmb newey(3)

*High Volatility Subsample
// Import the volatility variable (Vol), measured using stock returns over the previous five years
egen medVol=median(Vol)
gen HighVo1=1 if Vol>medVol
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if HighVol==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if HighVol==1

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if HighVol==1, fmb newey(3) 
}

*Real Option Intensive Industry
//Import Fama French 49 Industry (ffcode) 
gen roindustry=1 if ffcode==27|ffcode==28|ffcode==30|ffcode==22|ffcode==32|ffcode==35|ffcode==36|ffcode==37|ffcode==38|ffcode==12|ffcode==13
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if roindustry==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if roindustry==1

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if roindustry==1, fmb newey(3) 
}

*High Discretion Subsample
//Import High Discretion dummy 
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if HighDis==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if HighDis==1

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if HighDis==1, fmb newey(3) 
}

*Operating Efficiency Definition
gen EFneg=1 if EPS<=0
sum PE if EPS>0,detail
gen EFlow=1 if EPS>0&PE<=r(p50)
sum PE if EPS>0,detail
gen EFhigh=1 if PE>r(p50)

*Negative-earnings subsample
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if EFneg==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if EFneg==1

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if EFneg==1, fmb newey(3) 
}

*Standard-operating-efficiency subsample
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if EFlow==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if EFlow==1

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if EFlow==1, fmb newey(3) 
}

*High-operating-efficiency subsample
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if EFhigh==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if EFhigh==1

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if EFhigh==1, fmb newey(3) 
}


**# Tables
********************************************************************************
* Some tables are not generated using the outreg command and need to be arranged manually.
********************************************************************************

* Table 2 Panel B (using the joint sample for all models)
univar Price BVPS EPS CIPS CRPS RIPS NOAPS NOIPS ROIPS KGO3Y PB PE, dec(3)

* Table 3 (using model-specific samples after trimming the top and bottom 1% of P/B and P/E ratios)
asreg D_RIPS D_RIPS_lag1 if year>=1990, fmb newey(3) 
outreg2 using LID, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg D_RIPS D_RIPS_lag1 D_KGO3Y_lag1 if year>=1990, fmb newey(3) 
outreg2 using LID, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg D_KGO3Y D_KGO3Y_lag1 if year>=1990, fmb newey(3) 
outreg2 using LID, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg D_ROIPS D_ROIPS_lag1 D_NOAPS_lag1 if year>=1990, fmb newey(3)
outreg2 using LID, append excel dec(3) addstat("AdjR", e(r2_a)) tstat 
asreg D_NOAPS D_NOAPS_lag1 if year>=1990, fmb newey(3) 
outreg2 using LID, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg D_CRPS D_CRPS_lag1 D_CIPS_lag1  if year>=1990, fmb newey(3) 
outreg2 using LID, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg D_CIPS D_CIPS_lag1 if year>=1990, fmb newey(3) 
outreg2 using LID, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg D_NOALCI D_NOAPS_lag1 if year>=1990, fmb newey(3) 
outreg2 using LID, append excel dec(3) addstat("AdjR", e(r2_a)) tstat

* Table 4 (using the joint sample for all models)
univar Price VO95 VBO95 PutVO95 VA PutVA VO95KGO3Y GOKGO3Y VBO95KGO3Y PutVO95KGO3Y VFO95 VBFO95 PutVFO95 VFO96 VBFO96 PutVFO96 CEM VZhang PutZhang CallZhang, dec(3)

* Table 5 (using the joint sample for all models)
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y 
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y 

scalar drop _all

foreach var of varlist APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y {
univar T`var' 
scalar aT`var' = r(N) 
univar `var' 
scalar b`var' = r(N) 
scalar c`var'=aT`var'/ b`var'
display c`var'
}

* Table 6 (using the joint sample for all models)
asreg Price VO95, fmb newey(3) 
outreg2 using Explainability, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
foreach var of varlist VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var', fmb newey(3) 
outreg2 using Explainability, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
}

asreg Price VO95 PutVO95, fmb newey(3)
outreg2 using Decomposition, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg Price VO95 PutVA, fmb newey(3)
outreg2 using Decomposition, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg Price VO95 GOKGO3Y, fmb newey(3)
outreg2 using Decomposition, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg Price VO95 GOKGO3Y PutVO95K, fmb newey(3)
outreg2 using Decomposition, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg Price VFO95 PutVFO95, fmb newey(3)
outreg2 using Decomposition, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg Price VFO96 PutVFO96, fmb newey(3)
outreg2 using Decomposition, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
asreg Price CEM CallZhang PutZhang, fmb newey(3)
outreg2 using Decomposition, append excel dec(3) addstat("AdjR", e(r2_a)) tstat

* Table 7 (using the joint sample for all models)
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if HighVol==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if HighVol==1
asreg Price VO95 if HighVol==1, fmb newey(3) 
outreg2 using HighVol, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
foreach var of varlist  VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if HighVol==1, fmb newey(3) 
outreg2 using HighVol, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
}

univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if roindustry==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if roindustry==1
asreg Price VO95 if roindustry==1, fmb newey(3) 
outreg2 using roindustry, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
foreach var of varlist  VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if roindustry==1, fmb newey(3) 
outreg2 using roindustry, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
}

univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if HighDis==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if HighDis==1
asreg Price VO95 if HighDis==1, fmb newey(3) 
outreg2 using HighDis, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
foreach var of varlist  VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if HighDis==1, fmb newey(3) 
outreg2 using HighDis, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
}


* Table 8 (using the joint sample for all models)
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if EFneg==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if EFneg==1
asreg Price VO95 if EFneg==1, fmb newey(3) 
outreg2 using EFneg, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
foreach var of varlist  VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if EFneg==1, fmb newey(3) 
outreg2 using EFneg, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
}

univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if EFlow==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if EFlow==1
asreg Price VO95 if EFlow==1, fmb newey(3) 
outreg2 using EFlow, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
foreach var of varlist  VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if EFlow==1, fmb newey(3) 
outreg2 using EFlow, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
}

univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y if EFhigh==1
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y if EFhigh==1
asreg Price VO95 if EFhigh==1, fmb newey(3) 
outreg2 using EFhigh, replace excel dec(3) addstat("AdjR", e(r2_a)) tstat
foreach var of varlist  VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var' if EFhigh==1, fmb newey(3) 
outreg2 using EFhigh, append excel dec(3) addstat("AdjR", e(r2_a)) tstat
}


**# Additional Analysis with Analysts' Forecasts
********************************************************************************
* Additional forecast data were downloaded from I/B/E/S.
* The data were merged with the original database.
* Observations without the required forecast data or announcement date information were dropped.
* Important: This analysis is conducted on an alternative dataset (merged with analysts' forecasts), rather than the main dataset used in the primary tests. Although the models retain the same Equity Value, PVE, and APVE labels in the code, they actually represent values calculated using analysts' forecasts. For example, VO95, PVEO95, and APVEO95 below refer to the Equity Value, PVE, and APVE of O95AF, rather than O95.
********************************************************************************

*O95AF
xtset code year
gen BVPS_lag1=L.BVPS
gen RIPS=EPS-CostofEquity*BVPS_lag1
gen RIPS_lag1=L.RIPS
gen D_RIPS=RIPS/BVPS_lag1
gen D_RIPS_lag1=RIPS_lag1/BVPS_lag1

foreach var of varlist D_RIPS D_RIPS_lag1 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen O95w11=.

forval i = 1992/2022 {
asreg D_RIPS D_RIPS_lag1 if year<=`i', fmb
replace O95w11=_b[D_RIPS_lag1] if year==`i'
}

foreach var of varlist MEANEST_EPS1Y {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen FRIPS=MEANEST_EPS1Y/100-CostofEquity*BVPS
gen Ivo=FRIPS-O95w11*RIPS
gen Ivo_lag1=L.Ivo
gen D_Ivo=Ivo/BVPS_lag1
gen D_Ivo_lag1=Ivo_lag1/BVPS_lag1

foreach var of varlist D_Ivo D_Ivo_lag1 Ivo {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen O95w22=.

forval i = 1994/2022 {
asreg D_Ivo D_Ivo_lag1 if year<=`i', fmb
replace O95w22=_b[D_Ivo_lag1] if year==`i'
}

gen BetaO951=O95w11/(1+CostofEquity-O95w11)
gen BetaO952=(1+CostofEquity)/((1+CostofEquity-O95w11)*(1+CostofEquity-O95w22))
gen VO95=BVPS+BetaO951*RIPS+BetaO952*Ivo

*O95ADOAF
gen VO95_lag1=L.VO95
gen VO95_lag2=L.VO95_lag1
gen VO95_lag3=L.VO95_lag2
gen VO95_lag4=L.VO95_lag3
gen R1O95=(VO95-VO95_lag1)/VO95_lag1
gen R2O95=(VO95_lag1-VO95_lag2)/VO95_lag2
gen R3O95=(VO95_lag2-VO95_lag3)/VO95_lag3
gen R4O95=(VO95_lag3-VO95_lag4)/VO95_lag4
gen AverageO95=(R1O95+R2O95+R3O95+R4O95)/4
gen VarianceO95=((R1O95-AverageO95)^2+(R2O95-AverageO95)^2+(R3O95-AverageO95)^2+(R4O95-AverageO95)^2)/3
gen SDO95=sqrt(VarianceO95)
gen theta=2*CostofEquity/VarianceO95
gen thetaB=theta*BVPS
gen h=VO95/BVPS
sum theta, detail
sum thetaB, detail
sum h, detail
gen a0=thetaB*log10(thetaB/(1+thetaB))+2
gen a1=-1-thetaB/(1+thetaB)-thetaB*log10(thetaB/(1+thetaB))
gen l0=1
gen l1=1-h
forval i = 2/20 {
gen a`i'= (thetaB*(1+thetaB)^`i'- thetaB^`i'*(`i'+thetaB))/(`i'*(`i'-1)*(1+thetaB)^`i')
local j=`i'-1
local k=`i'-2
gen l`i'= ((2*`i'-1-h)*l`j'-(`i'-1)*l`k')/`i'
}
gen Va=a0*l0
forval i = 1/20 {
replace Va= a`i'*l`i'+Va
}
replace Va=1 if h<=0&!missing(Va)
gen VA=Va*BVPS
//

*O95ABOAF
gen T=5
gen O95d1=(ln(VO95/BVPS)+(rf+VarianceO95/2)*T)/(SDO95*sqrt(T))
gen O95d2=O95d1-SDO95*sqrt(T)
gen O95Nd1=normal(O95d1)
gen O95Nd2=normal(O95d2)
gen O95Call=VO95*O95Nd1-BVPS*exp(-rf*T)*O95Nd2
replace O95Call=0 if VO95<=BVPS&!missing(BVPS)
gen VBO95=BVPS+O95Call
replace VBO95=. if missing(O95d1)
replace VBO95=BVPS if VO95<=BVPS&!missing(BVPS)
drop T 

*O95GOAF
gen D_KGO3Y=KGO3Y/BVPS_lag1
gen KGO3Y_lag1=L.KGO3Y
gen D_KGO3Y_lag1=KGO3Y_lag1/BVPS_lag1
winsor2 D_KGO3Y, cuts(1 99) by(year_)
rename D_KGO3Y oD_KGO3Y
rename D_KGO3Y_w D_KGO3Y
winsor2 D_KGO3Y_lag1, cuts(1 99) by(year_)
rename D_KGO3Y_lag1 oD_KGO3Y_lag1
rename D_KGO3Y_lag1_w D_KGO3Y_lag1

gen O95KGO3Yw11=.
gen O95KGO3Yw12=.
forval i = 1993/2022 {
asreg D_RIPS D_RIPS_lag1 D_KGO3Y_lag1 if year<=`i', fmb
replace O95KGO3Yw11=_b[D_RIPS_lag1] if year==`i'
replace O95KGO3Yw12=_b[D_KGO3Y_lag1] if year==`i'
}

gen O95KGO3Yw22=.
forval i = 1993/2022 {
asreg D_KGO3Y D_KGO3Y_lag1 if year<=`i', fmb
replace O95KGO3Yw22=_b[D_KGO3Y_lag1] if year==`i'
}

gen IvoG=FRIPS-O95KGO3Yw11*RIPS-O95KGO3Yw12*KGO3Y
gen IvoG_lag1=L.IvoG
gen D_IvoG=IvoG/BVPS_lag1
gen D_IvoG_lag1=IvoG_lag1/BVPS_lag1

foreach var of varlist D_IvoG D_IvoG_lag1 IvoG {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen O95KGO3Yw33=.

forval i = 1997/2022 {
asreg D_IvoG D_IvoG_lag1 if year<=`i', fmb
replace O95KGO3Yw33=_b[D_IvoG_lag1] if year==`i'
}

gen BetaO95KGO3Y1=O95KGO3Yw11/(1+CostofEquity-O95KGO3Yw11)
gen BetaO95KGO3Y2=(1+CostofEquity)*O95KGO3Yw12/((1+CostofEquity-O95KGO3Yw11)*(1+CostofEquity-O95KGO3Yw22))
gen BetaO95KGO3Y3=(1+CostofEquity)/((1+CostofEquity-O95KGO3Yw11)*(1+CostofEquity-O95KGO3Yw33))
gen VO95KGO3Y=BVPS+BetaO95KGO3Y1*RIPS+BetaO95KGO3Y2*KGO3Y+BetaO95KGO3Y3*IvoG

*O95GOABOAF
gen VO95KGO3Y_lag1=L.VO95KGO3Y
gen VO95KGO3Y_lag2=L.VO95KGO3Y_lag1
gen VO95KGO3Y_lag3=L.VO95KGO3Y_lag2
gen VO95KGO3Y_lag4=L.VO95KGO3Y_lag3
gen R1O95KGO3Y=(VO95KGO3Y-VO95KGO3Y_lag1)/VO95KGO3Y_lag1
gen R2O95KGO3Y=(VO95KGO3Y_lag1-VO95KGO3Y_lag2)/VO95KGO3Y_lag2
gen R3O95KGO3Y=(VO95KGO3Y_lag2-VO95KGO3Y_lag3)/VO95KGO3Y_lag3
gen R4O95KGO3Y=(VO95KGO3Y_lag3-VO95KGO3Y_lag4)/VO95KGO3Y_lag4
gen AverageO95KGO3Y=(R1O95KGO3Y+R2O95KGO3Y+R3O95KGO3Y+R4O95KGO3Y)/4
gen VarianceO95KGO3Y=((R1O95KGO3Y-AverageO95KGO3Y)^2+(R2O95KGO3Y-AverageO95KGO3Y)^2+(R3O95KGO3Y-AverageO95KGO3Y)^2+(R4O95KGO3Y-AverageO95KGO3Y)^2)/3
gen SDO95KGO3Y=sqrt(VarianceO95KGO3Y)

gen T=5
gen O95KGO3Yd1=(ln(VO95KGO3Y/BVPS)+(rf+VarianceO95KGO3Y/2)*T)/(SDO95KGO3Y*sqrt(T))
gen O95KGO3Yd2=O95KGO3Yd1-SDO95KGO3Y*sqrt(T)
gen O95KGO3YNd1=normal(O95KGO3Yd1)
gen O95KGO3YNd2=normal(O95KGO3Yd2)
gen O95KGO3YCall=VO95KGO3Y*O95KGO3YNd1-BVPS*exp(-rf*T)*O95KGO3YNd2
replace O95KGO3YCall=0 if VO95KGO3Y<=BVPS&!missing(BVPS)
gen VBO95KGO3Y=BVPS+O95KGO3YCall
replace VBO95KGO3Y=. if missing(O95KGO3Yd1)
replace VBO95KGO3Y=BVPS if VO95KGO3Y<=BVPS&!missing(BVPS)
drop T 


*FO95AF
gen NOAPS_lag1=L.NOAPS
gen ROIPS=NOIPS-CostofEquity*NOAPS_lag1
gen ROIPS_lag1=L.ROIPS
gen D_ROIPS=ROIPS/BVPS_lag1
gen D_ROIPS_lag1=ROIPS_lag1/BVPS_lag1
gen D_NOAPS=NOAPS/BVPS_lag1
gen D_NOAPS_lag1=NOAPS_lag1/BVPS_lag1

foreach var of varlist D_ROIPS D_ROIPS_lag1 D_NOAPS D_NOAPS_lag1 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen FO95w11=.
gen FO95w12=.
gen FO95w22=.
gen FO95w31=.
gen FO95w41=.

forval i = 1992/2022 {
asreg D_ROIPS D_ROIPS_lag1 D_NOAPS_lag1 if year<=`i', fmb
replace FO95w11=_b[D_ROIPS_lag1] if year==`i'
replace FO95w12=_b[D_NOAPS_lag1] if year==`i'
}

forval i = 1992/2022 {
asreg D_NOAPS D_NOAPS_lag1 if year<=`i', fmb
replace FO95w22=_b[D_NOAPS_lag1] if year==`i'
}

gen FNOIPS=(NOI/CommonShares-ITEM1751/CommonShares)+MEANEST_EPS1Y/100
gen FRNOIPS=FNOIPS-CostofEquity*NOAPS
gen FNOAPS=(NOA/CommonShares-ITEM3501/CommonShares)+MEANEST_BVPS1Y/100

gen IvoFO951=FRNOIPS-FO95w11*ROIPS-FO95w12*NOAPS
gen IvoFO951_lag1=L.IvoFO951
gen D_IvoFO951=IvoFO951/BVPS_lag1
gen D_IvoFO951_lag1=IvoFO951_lag1/BVPS_lag1

gen IvoFO952=FNOAPS-FO95w22*NOAPS
gen IvoFO952_lag1=L.IvoFO952
gen D_IvoFO952=IvoFO952/BVPS_lag1
gen D_IvoFO952_lag1=IvoFO952_lag1/BVPS_lag1

foreach var of varlist D_IvoFO951 D_IvoFO951_lag1 D_IvoFO952 D_IvoFO952_lag1 IvoFO951 IvoFO952 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

forval i = 1994/2022 {
asreg D_IvoFO951 D_IvoFO951_lag1 if year<=`i', fmb
replace FO95w31=_b[D_IvoFO951_lag1] if year==`i'
}

forval i = 1998/2022 {
asreg D_IvoFO952 D_IvoFO952_lag1 if year<=`i', fmb
replace FO95w41=_b[D_IvoFO952_lag1] if year==`i'
}

gen BetaFO951=FO95w11/(1+CostofEquity-FO95w11)
gen BetaFO952=FO95w12*(1+CostofEquity)/((1+CostofEquity-FO95w11)*(1+CostofEquity-FO95w22))
gen BetaFO953=(1+CostofEquity)/((1+CostofEquity-FO95w11)*(1+CostofEquity-FO95w31))
gen BetaFO954=(FO95w12*(1+CostofEquity)/((1+CostofEquity-FO95w11)*(1+CostofEquity-FO95w22)))/(1+CostofEquity-FO95w41)
gen VFO95=BVPS+BetaFO951*ROIPS+BetaFO952*NOAPS+BetaFO953*IvoFO951+BetaFO954*IvoFO952

*FO95ABOAF
gen VFO95_lag1=L.VFO95
gen VFO95_lag2=L.VFO95_lag1
gen VFO95_lag3=L.VFO95_lag2
gen VFO95_lag4=L.VFO95_lag3
gen R1FO95=(VFO95-VFO95_lag1)/VFO95_lag1
gen R2FO95=(VFO95_lag1-VFO95_lag2)/VFO95_lag2
gen R3FO95=(VFO95_lag2-VFO95_lag3)/VFO95_lag3
gen R4FO95=(VFO95_lag3-VFO95_lag4)/VFO95_lag4
gen AverageFO95=(R1FO95+R2FO95+R3FO95+R4FO95)/4
gen VarianceFO95=((R1FO95-AverageFO95)^2+(R2FO95-AverageFO95)^2+(R3FO95-AverageFO95)^2+(R4FO95-AverageFO95)^2)/3
gen SDFO95=sqrt(VarianceFO95)

gen T=5
gen FO95d1=(ln(VFO95/BVPS)+(rf+VarianceFO95/2)*T)/(SDFO95*sqrt(T))
gen FO95d2=FO95d1-SDFO95*sqrt(T)
gen FO95Nd1=normal(FO95d1)
gen FO95Nd2=normal(FO95d2)
gen FO95Call=VFO95*FO95Nd1-BVPS*exp(-rf*T)*FO95Nd2
replace FO95Call=0 if VFO95<=BVPS&!missing(BVPS)
gen VBFO95=BVPS+FO95Call
replace VBFO95=. if missing(FO95d1)
replace VBFO95=BVPS if VFO95<=BVPS&!missing(BVPS)
drop T 

**FO96AF
gen CIPS_lag1=L.CIPS
gen CRPS_lag1=L.CRPS
gen D_CIPS=CIPS/BVPS_lag1
gen D_CIPS_lag1=CIPS_lag1/BVPS_lag1
gen D_CRPS=CRPS/BVPS_lag1
gen D_CRPS_lag1=CRPS_lag1/BVPS_lag1
gen D_NOALCI=(NOAPS-CIPS)/BVPS_lag1

foreach var of varlist D_CRPS D_CRPS_lag1 D_CIPS D_CIPS_lag1 D_NOALCI {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen FO96r11=.
gen FO96r12=.
gen FO96r22=.
gen FO96del=.
gen FO96w31=.
gen FO96w41=.

forval i = 1996/2022 {
asreg D_CRPS D_CRPS_lag1 D_CIPS_lag1  if year>1994&year<=`i', fmb
replace FO96r11=_b[D_CRPS_lag1] if year==`i'
replace FO96r12=_b[D_CIPS_lag1] if year==`i'
}

forval i = 1990/2022 {
asreg D_CIPS D_CIPS_lag1  if year<=`i', fmb
replace FO96r22=_b[D_CIPS_lag1] if year==`i'
}

forval i = 1990/2022 {
asreg D_NOALCI D_NOAPS_lag1 if year<=`i', fmb
replace FO96del=_b[D_NOAPS_lag1] if year==`i'
}

gen FNOIPS2=(NOI/CommonShares-ITEM1751/CommonShares)+MEANEST_EPS2Y/100
gen FRNOIPS2=FNOIPS2-CostofEquity*(NOAPS+FNOIPS-ITEM5507)

foreach var of varlist FRNOIPS FRNOIPS2 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen IvoFO961=FRNOIPS-(FO96r11*ROIPS+(FO96r12-(1+CostofEquity-FO96del))*CIPS+((1+CostofEquity-FO96del)*(FO96r11-FO96del))*NOAPS_lag1)
gen IvoFO961_lag1=L.IvoFO961
gen D_IvoFO961=IvoFO961/BVPS_lag1
gen D_IvoFO961_lag1=IvoFO961_lag1/BVPS_lag1

foreach var of varlist D_IvoFO961 D_IvoFO961_lag1 IvoFO961 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

forval i = 1998/2022 {
asreg D_IvoFO961 D_IvoFO961_lag1 if year<=`i', fmb
replace FO96w31=_b[D_IvoFO961_lag1] if year==`i'
}

gen IvoFO962=(FRNOIPS2-(FO96r11^2*ROIPS+(FO96r12*(FO96r11+FO96r22)-((1+CostofEquity-FO96del)*(FO96del+FO96r22)))*CIPS+((1+CostofEquity-FO96del)*(FO96r11^2-FO96del^2))*NOAPS_lag1+(FO96r11+FO96w31)*IvoFO961))/(FO96r12-(1+CostofEquity-FO96del))

gen IvoFO962_lag1=L.IvoFO962
gen D_IvoFO962=IvoFO962/BVPS_lag1
gen D_IvoFO962_lag1=IvoFO962_lag1/BVPS_lag1

foreach var of varlist D_IvoFO962 D_IvoFO962_lag1 IvoFO962 {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

forval i = 2000/2022 {
asreg D_IvoFO962 D_IvoFO962_lag1 if year<=`i', fmb
replace FO96w41=_b[D_IvoFO962_lag1] if year==`i'
}

gen FO96phi11=1/(1+CostofEquity-FO96r11) 
gen FO96phi22=1/(1+CostofEquity-FO96r22) 
gen FO96phi31=1/(1+CostofEquity-FO96w31) 
gen FO96phi41=1/(1+CostofEquity-FO96w41)
gen FO96eta=FO96phi11*FO96r12-1

gen BetaFO961=FO96phi11*FO96r11
gen BetaFO962=FO96eta*(1+CostofEquity)*FO96phi22
gen BetaFO963=FO96phi11*(1+CostofEquity)*(FO96r11-FO96del)
gen BetaFO964=(1+CostofEquity)*FO96phi11*FO96phi31
gen BetaFO965=(1+CostofEquity)*FO96phi41*FO96phi22*FO96eta

gen VFO96=BVPS+BetaFO961*ROIPS+BetaFO962*CIPS+BetaFO963*NOAPS_lag1+BetaFO964*IvoFO961+BetaFO965*IvoFO962
sum VFO96, detail

*FO96ABOAF
gen VFO96_lag1=L.VFO96
gen VFO96_lag2=L.VFO96_lag1
gen VFO96_lag3=L.VFO96_lag2
gen VFO96_lag4=L.VFO96_lag3
gen R1FO96=(VFO96-VFO96_lag1)/VFO96_lag1
gen R2FO96=(VFO96_lag1-VFO96_lag2)/VFO96_lag2
gen R3FO96=(VFO96_lag2-VFO96_lag3)/VFO96_lag3
gen R4FO96=(VFO96_lag3-VFO96_lag4)/VFO96_lag4
gen AverageFO96=(R1FO96+R2FO96+R3FO96+R4FO96)/4
gen VarianceFO96=((R1FO96-AverageFO96)^2+(R2FO96-AverageFO96)^2+(R3FO96-AverageFO96)^2+(R4FO96-AverageFO96)^2)/3
gen SDFO96=sqrt(VarianceFO96)

gen T=5
gen FO96d1=(ln(VFO96/BVPS)+(rf+VarianceFO96/2)*T)/(SDFO96*sqrt(T))
gen FO96d2=FO96d1-SDFO96*sqrt(T)
gen FO96Nd1=normal(FO96d1)
gen FO96Nd2=normal(FO96d2)
gen FO96Call=VFO96*FO96Nd1-BVPS*exp(-rf*T)*FO96Nd2
replace FO96Call=0 if VFO96<=BVPS&!missing(BVPS)
gen VBFO96=BVPS+FO96Call
replace VBFO96=. if missing(FO96d1)
replace VBFO96=BVPS if VFO96<=BVPS&!missing(BVPS)
drop T 

**CEMAF
gen ROEAF=MEANEST_EPS1Y/100/BVPS
foreach var of varlist ROEAF {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

gen CEM=ROEAF*BVPS/CostofEquity

*CEGOABOAF
gen PutZhang=(BVPS-(ROEAF*BVPS)/CostofEquity)/(1+CostofEquity)
replace PutZhang=0 if PutZhang<=0
gen growthaf=(MEANEST_BVPS1Y/100-BVPS)/BVPS
foreach var of varlist growthaf {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}
bysort year_ ffcode:  egen gffcode=mean(growthaf) 
gen Ggffcode=BVPS*gffcode

gen CallZhang=((ROEAF*Ggffcode)/CostofEquity-Ggffcode)/(1+CostofEquity)
replace CallZhang=0 if CallZhang4<=0
gen VZhang=ROEAF*BVPS/CostofEquity+CallZhang+PutZhang

*PVE
gen PVEO95=(VO95-Price)/Price
gen PVEVBO95=(VBO95-Price)/Price
gen PVEVA=(VA-Price)/Price
gen PVEFO95=(VFO95-Price)/Price
gen PVEFO96=(VFO96-Price)/Price
gen PVEVBFO95=(VBFO95-Price)/Price
gen PVEVBFO96=(VBFO96-Price)/Price
gen PVEO95KGO3Y=(VO95KGO3Y-Price)/Price
gen PVEVBO95KGO3Y=(VBO95KGO3Y-Price)/Price
gen PVECEM=(CEM-Price)/Price
gen PVEZhang=(VZhang-Price)/Price

*Construct joint sample
drop if missing(PVEO95)
drop if missing(PVEVBO95)
drop if missing(PVEVA)
drop if missing(PVEFO95)
drop if missing(PVEFO96)
drop if missing(PVEVBFO95)
drop if missing(PVEVBFO96)
drop if missing(PVEZhang)
drop if missing(PVECEM)
drop if missing(PVEO95KGO3Y)
drop if missing(PVEVBO95KGO3Y)

*APVE
gen APVEO95=abs(VO95-Price)/Price
gen APVEVBO95=abs(VBO95-Price)/Price
gen APVEVA=abs(VA-Price)/Price
gen APVEFO95=abs(VFO95-Price)/Price
gen APVEFO96=abs(VFO96-Price)/Price
gen APVEVBFO95=abs(VBFO95-Price)/Price
gen APVEVBFO96=abs(VBFO96-Price)/Price
gen APVEO95KGO3Y=abs(VO95KGO3Y-Price)/Price
gen APVEVBO95KGO3Y=abs(VBO95KGO3Y-Price)/Price
gen APVECEM=abs(CEM-Price)/Price
gen APVEZhang=abs(VZhang-Price)/Price

*PVE and APVE
univar PVEO95 PVEVBO95 PVEVA PVEFO95 PVEFO96 PVEVBFO95 PVEVBFO96 PVECEM PVEZhang PVEO95KGO3Y PVEVBO95KGO3Y 
univar APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y 

*Frequency of Accuracy
gen	TAPVEO95 =APVEO95  if APVEO95 <=0.15
gen	TAPVEVBO95=APVEVBO95 if APVEVBO95<=0.15
gen	TAPVEVA=APVEVA if APVEVA<=0.15
gen	TAPVEFO95=APVEFO95 if APVEFO95<=0.15
gen	TAPVEVBFO95=APVEVBFO95 if APVEVBFO95<=0.15
gen	TAPVEFO96=APVEFO96 if APVEFO96<=0.15
gen	TAPVEVBFO96=APVEVBFO96 if APVEVBFO96<=0.15
gen TAPVECEM=APVECEM if APVECEM<=0.15
gen TAPVEZhang=APVEZhang if APVEZhang<=0.15
gen TAPVEO95KGO3Y=APVEO95KGO3Y  if APVEO95KGO3Y<=0.15
gen TAPVEVBO95KGO3Y=APVEVBO95KGO3Y if APVEVBO95KGO3Y<=0.15

scalar drop _all

foreach var of varlist APVEO95 APVEVBO95 APVEVA APVEFO95 APVEFO96 APVEVBFO95 APVEVBFO96 APVECEM APVEZhang APVEO95KGO3Y APVEVBO95KGO3Y {
univar T`var' 
scalar aT`var' = r(N) 
univar `var' 
scalar b`var' = r(N) 
scalar c`var'=aT`var'/ b`var'
display c`var'
}

*Explainability
foreach var of varlist Price VO95 VBO95 VA VFO95 VBFO95 VFO96 VBFO96 VZhang CEM VO95KGO3Y VBO95KGO3Y {
winsor2 `var', cuts(1 99) by(year_)
rename `var' o`var'
rename `var'_w `var'
}

foreach var of varlist VO95 VBO95 VA VO95KGO3Y VBO95KGO3Y VFO95 VBFO95 VFO96 VBFO96 CEM VZhang {
asreg Price `var', fmb newey(3) 
}

